/* Clean Data and Merge Data Files */

clear
drop _all
graph drop _all

*************************************
*************************************
*************************************
*************************************
/* Clean Data and Merge PELA Data Files */
*************************************
*************************************
*************************************
*************************************

/* Data: PELA (Salamanca) -- Survey with Latin American Elites */

/* PELA Paraguay */

use "da91par.dta"

/* Define depedent variables (parties) */

gen parties = .

replace parties = 1 if partido==2 
replace parties = 2 if partido==1
replace parties = 4 if partido==3 | partido==4 | partido==5 | partido==6 | partido==7

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 1
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 1
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ROES101 "Public Ownership of Firms" // Prepare independent variables
replace ROES101=(ROES101-1)/6
label define ROES101_l 0 "Disagree a lot" 1 "Agree a lot"
label values ROES101 ROES101_l
rename ROES101 publicfirms

label variable ROES104 "Reduce Income Inequality"
replace ROES104=(ROES104-1)/6
label define ROES104_l 0 "Disagree a lot" 1 "Agree a lot"
label values ROES104 ROES104_l
rename ROES104 reduceinequality

label variable VAL1 "Support Same-Sex Marriage"
recode VAL1 (99 = .)
replace VAL1=(VAL1-1)/9
label define VAL1_l 0 "Strongly disapprove" 1 "Strongly approve"
label values VAL1 VAL1_l
rename VAL1 samesex

recode DEM3 (2 = 0)
label variable DEM3 "Support for Democracy"
label define DEM3a 1 "Democracy is always preferable" 0 "Democracy can be replaced during crises"
label values DEM3 DEM3a
rename DEM3 democracy

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy

/* Save new file */

save "PELA_Paraguay.dta", replace

*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

clear
drop _all
graph drop _all

/* Data: PELA (Salamanca) -- Survey with Latin American Elites */

/* PELA Honduras */

use "da92hon.dta"

/* Define depedent variables (parties) */

gen parties = .

replace parties = 1 if partido==1
replace parties = 2 if partido==2
replace parties = 4 if partido==3 | partido==4 | partido==5

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 2
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 1
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ROES101 "Public Ownership of Firms" // Prepare independent variables
replace ROES101=(ROES101-1)/6
label define ROES101_l 0 "Disagree a lot" 1 "Agree a lot"
label values ROES101 ROES101_l
rename ROES101 publicfirms

label variable ROES104 "Reduce Income Inequality"
replace ROES104=(ROES104-1)/6
label define ROES104_l 0 "Disagree a lot" 1 "Agree a lot"
label values ROES104 ROES104_l
rename ROES104 reduceinequality

label variable VAL1 "Support Same-Sex Marriage"
replace VAL1=(VAL1-1)/9
label define VAL1_l 0 "Strongly disapprove" 1 "Strongly approve"
label values VAL1 VAL1_l
rename VAL1 samesex

recode DEM3 (2 = 0)
label variable DEM3 "Support for Democracy"
label define DEM3a 1 "Democracy is always preferable" 0 "Democracy can be replaced during crises"
label values DEM3 DEM3a
rename DEM3 democracy

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy

/* Save new file */

save "PELA_Honduras.dta", replace

*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

clear
drop _all
graph drop _all

/* Data: PELA (Salamanca) -- Survey with Latin American Elites */

/* PELA Nicaragua */

use "Da86nica.dta"

/* Define depedent variables (parties) */

gen parties = .

replace parties = 1 if partido==3
replace parties = 3 if partido==1
replace parties = .a if partido==2

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 3
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 1
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ROES101 "Public Ownership of Firms" // Prepare independent variables
recode ROES101 (9 = .)
replace ROES101=(ROES101-1)/6
label define ROES101_l 0 "Disagree a lot" 1 "Agree a lot"
label values ROES101 ROES101_l
rename ROES101 publicfirms

label variable ROES104 "Reduce Income Inequality"
replace ROES104=(ROES104-1)/6
label define ROES104_l 0 "Disagree a lot" 1 "Agree a lot"
label values ROES104 ROES104_l
rename ROES104 reduceinequality

label variable VAL1 "Support Same-Sex Marriage"
recode VAL1 (99 = .)
replace VAL1=(VAL1-1)/9
label define VAL1_l 0 "Strongly disapprove" 1 "Strongly approve"
label values VAL1 VAL1_l
rename VAL1 samesex

recode DEM3 (2 = 0) (9 = .)
label variable DEM3 "Support for Democracy"
label define DEM3a 1 "Democracy is always preferable" 0 "Democracy can be replaced during crises"
label values DEM3 DEM3a
rename DEM3 democracy

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy

/* Save new file */

save "PELA_Nicaragua.dta", replace

*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

clear
drop _all
graph drop _all

/* Data: PELA (Salamanca) -- Survey with Latin American Elites */

use "PELA_Paraguay.dta"

merge m:m parties country database publicfirms reduceinequality samesex democracy ///
		using "PELA_Honduras.dta"
		
drop _merge
		
merge m:m parties country database publicfirms reduceinequality samesex democracy ///
		using "PELA_Nicaragua.dta"
		
drop _merge

save "Final_PELA_merged.dta", replace

*************************************
*************************************
*************************************
*************************************
/* Clean Data and Merge LAPOP Data Files */
*************************************
*************************************
*************************************
*************************************

/* Data: LAPOP (Vanderbilt) -- Survey with Latin American Voters */

/* LAPOP Paraguay */

clear
drop _all
graph drop _all

use "1311870907Paraguay LAPOP AmericasBarometer 2016 V1.0 W.dta"

/* Define depedent variables (parties) */

gen parties = 0

replace parties = 1 if vb11==1202
replace parties = 2 if vb11==1201
replace parties = 4 if vb11==1203 | vb11==1205 | vb11==1206 | vb11==1207 | vb11==1209 | vb11==1210 | vb11==1212 | vb11==1215 | vb11==1218 | vb11==1277
replace parties =.a if parties==0

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 1
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 2
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ros1 "Public Ownership of Firms" // Prepare independent variables
replace ros1=(ros1-1)/6
label define ros1_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros1 ros1_l
rename ros1 publicfirms

label variable ros4 "Reduce Income Inequality"
replace ros4=(ros4-1)/6
label define ros4_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros4 ros4_l
rename ros4 reduceinequality

label variable d6 "Support Same-Sex Marriage"
replace d6=(d6-1)/9
label define d6_l 0 "Strongly disapprove" 1 "Strongly approve"
label values d6 d6_l
rename d6 samesex

label variable ing4 "Support for Democracy (continuous)
replace ing4=(ing4-1)/6
label define ing4_l 0 "Strongly disagree" 1 "Strongly agree"
label values ing4 ing4_l
rename ing4 democracy_cont

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy_cont

/* Save new file */

save "LAPOP_Paraguay.dta", replace

*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

/* Data: LAPOP (Vanderbilt) -- Survey with Latin American Voters */

/* LAPOP Paraguay */

clear
drop _all
graph drop _all

use "1311870907Paraguay LAPOP AmericasBarometer 2016 V1.0 W.dta"

/* Define depedent variables (parties) */

gen parties = 0

replace parties = 1 if vb11==1202
replace parties = 2 if vb11==1201
replace parties = 4 if vb11==1203 | vb11==1205 | vb11==1206 | vb11==1207 | vb11==1209 | vb11==1210 | vb11==1212 | vb11==1215 | vb11==1218 | vb11==1277
replace parties =.a if parties==0

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 1
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 2
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ros1 "Public Ownership of Firms" // Prepare independent variables
replace ros1=(ros1-1)/6
label define ros1_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros1 ros1_l
rename ros1 publicfirms

label variable ros4 "Reduce Income Inequality"
replace ros4=(ros4-1)/6
label define ros4_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros4 ros4_l
rename ros4 reduceinequality

label variable d6 "Support Same-Sex Marriage"
replace d6=(d6-1)/9
label define d6_l 0 "Strongly disapprove" 1 "Strongly approve"
label values d6 d6_l
rename d6 samesex

label variable ing4 "Support for Democracy (continuous)
replace ing4=(ing4-1)/6
label define ing4_l 0 "Strongly disagree" 1 "Strongly agree"
label values ing4 ing4_l
rename ing4 democracy_cont

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy_cont

/* Save new file */

save "LAPOP_Paraguay.dta", replace

*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

/* Data: LAPOP (Vanderbilt) -- Survey with Latin American Voters */

/* LAPOP Paraguay */

clear
drop _all
graph drop _all

use "1311870907Paraguay LAPOP AmericasBarometer 2016 V1.0 W.dta"

/* Define depedent variables (parties) */

gen parties = 0

replace parties = 1 if vb11==1202
replace parties = 2 if vb11==1201
replace parties = 4 if vb11==1203 | vb11==1205 | vb11==1206 | vb11==1207 | vb11==1209 | vb11==1210 | vb11==1212 | vb11==1215 | vb11==1218 | vb11==1277
replace parties =.a if parties==0

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 1
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 2
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ros1 "Public Ownership of Firms" // Prepare independent variables
replace ros1=(ros1-1)/6
label define ros1_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros1 ros1_l
rename ros1 publicfirms

label variable ros4 "Reduce Income Inequality"
replace ros4=(ros4-1)/6
label define ros4_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros4 ros4_l
rename ros4 reduceinequality

label variable d6 "Support Same-Sex Marriage"
replace d6=(d6-1)/9
label define d6_l 0 "Strongly disapprove" 1 "Strongly approve"
label values d6 d6_l
rename d6 samesex

label variable ing4 "Support for Democracy (continuous)
replace ing4=(ing4-1)/6
label define ing4_l 0 "Strongly disagree" 1 "Strongly agree"
label values ing4 ing4_l
rename ing4 democracy_cont

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy_cont

/* Save new file */

save "LAPOP_Paraguay.dta", replace

*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

/* Data: LAPOP (Vanderbilt) -- Survey with Latin American Voters */

/* LAPOP Honduras */

clear
drop _all
graph drop _all

use "1252173714Honduras LAPOP AmericasBarometer 2016 V1.0_W.dta"

/* Define depedent variables (parties) */

gen parties = 0

replace parties = 1 if vb11==402
replace parties = 2 if vb11==401
replace parties = 4 if vb11==405 | vb11==406 | vb11==407 | vb11==477
replace parties =.a if parties==0

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 2
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 2
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ros1 "Public Ownership of Firms" // Prepare independent variables
replace ros1=(ros1-1)/6
label define ros1_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros1 ros1_l
rename ros1 publicfirms

label variable ros4 "Reduce Income Inequality"
replace ros4=(ros4-1)/6
label define ros4_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros4 ros4_l
rename ros4 reduceinequality

label variable d6 "Support Same-Sex Marriage"
replace d6=(d6-1)/9
label define d6_l 0 "Strongly disapprove" 1 "Strongly approve"
label values d6 d6_l
rename d6 samesex

label variable ing4 "Support for Democracy (continuous)
replace ing4=(ing4-1)/6
label define ing4_l 0 "Strongly disagree" 1 "Strongly agree"
label values ing4 ing4_l
rename ing4 democracy_cont

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy_cont

/* Save new file */

save "LAPOP_Honduras.dta", replace


*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

/* Data: LAPOP (Vanderbilt) -- Survey with Latin American Voters */

/* LAPOP Nicaragua */

clear
drop _all
graph drop _all

use "860821151Nicaragua LAPOP AmericasBarometer 2012 Rev1_W.dta"

/* Define depedent variables (parties) */

gen parties = 0

replace parties = 1 if vb11==504
replace parties = 3 if vb11==502
replace parties = 4 if vb11==501 | vb11==77
replace parties =.a if parties==0

label define partiesb 1 "Liberals" 2 "Conservatives" 3 "Socialists" 4 "Others"
label values parties partiesb
label variable parties "Party Family"

/* Define country */

gen country = 3
label variable country "Country"
label define country_l 1 "Paraguay" 2 "Honduras" 3 "Nicaragua"
label values country country_l

/* Define dataset */

gen database = 2
label variable database "Database (PELA or LAPOP)"
label define database_l 1 "PELA" 2 "LAPOP"
label values database database_l

/* Define independent variables */

label variable ros1 "Public Ownership of Firms" // Prepare independent variables
replace ros1=(ros1-1)/6
label define ros1_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros1 ros1_l
rename ros1 publicfirms

label variable ros4 "Reduce Income Inequality"
replace ros4=(ros4-1)/6
label define ros4_l 0 "Disagree a lot" 1 "Agree a lot"
label values ros4 ros4_l
rename ros4 reduceinequality

label variable d6 "Support Same-Sex Marriage"
replace d6=(d6-1)/9
label define d6_l 0 "Strongly disapprove" 1 "Strongly approve"
label values d6 d6_l
rename d6 samesex

label variable ing4 "Support for Democracy (continuous)
replace ing4=(ing4-1)/6
label define ing4_l 0 "Strongly disagree" 1 "Strongly agree"
label values ing4 ing4_l
rename ing4 democracy_cont

/* Keep only relevant variables */

keep parties country database publicfirms reduceinequality samesex democracy_cont

/* Save new file */

save "LAPOP_Nicaragua.dta", replace

*************************************
*************************************
/* Clean Data and Merge Data Files */
*************************************
*************************************

clear
drop _all
graph drop _all

/* Data: LAPOP (Vanderbilt) -- Survey with Latin American Voters */

use "LAPOP_Paraguay.dta"

merge m:m parties country database publicfirms reduceinequality samesex democracy_cont ///
		using "LAPOP_Honduras.dta"
		
drop _merge
		
merge m:m parties country database publicfirms reduceinequality samesex democracy_cont ///
		using "LAPOP_Nicaragua.dta"
		
drop _merge

save "Final_LAPOP_merged.dta", replace

*************************************
*************************************
*************************************
*************************************
/* Clean Data and Merge LAPOP Data Files */
*************************************
*************************************
*************************************
*************************************

clear
drop _all
graph drop _all

/* Data: PELA (Salamanca) -- Survey with Latin American Elites */

use "Final_PELA_merged.dta"

merge m:m parties country database publicfirms reduceinequality samesex ///
		using "Final_LAPOP_merged.dta"
		
save "Merged_PELA_LAPOP.dta", replace




